<?php
/**
 * this files is default template for displaying forms
 *
 * Needed for quick formationg and form development
 * 
 * Useful if you want to create your own template class. Althought for 
 * complicate forms you will alwasy use custome formating which means that you
 * will not use Kodform display method.
 *
 *
 * @copyright 	Copyright (c) 2006 Boris Tomic (kodmasin.net)
 * @category 	Kodform
 * @package 	Kodform
 * @author 		Boris Tomic
 * @license 	http://boris.kodmasin.net/kodform4:license The BSD License
 *
 */

require_once 'Kodform/Attributes.php';

$fieldAttributes = new Kodform_Attributes();
$fieldAttributes->required->style = "border: 1px solid blue;";
$fieldAttributes->error->style = "border: 1px solid red;";
$fieldAttributes->normal->style = "border: 1px solid black;";

if($this->isSubmited() && !$this->isValid()):
	?>
<div style="background: white; color: red; border:2px solid red;padding-left:20px;">Errors!</div>
<div style="background: red;">
<table>
	<?php
	foreach($this->getErrors() as $element => $errors):
	?>
	<tr>
	<!--<td style="text-align: right;"> <?php print $element;?>:</td>-->
	<td>
		<?php 
		foreach($errors as $error):
			print $error; 
			?>
		<br />
			<?php
		endforeach;
		?>
	</td>
	</tr>
		<?php
		endforeach;
	?>
</table>
</div>
	<?php
endif;
?>

<form style="background: #CCCCCC; border: 1px solid black;" id="<?php print $this->id;?>" action="<?php print $this->action;?>" method="<?php print $this->methods[$this->method];?>">
<table>
<?php
foreach($this->elements as $element){
	?>
<tr><td style="vertical-align: top; text-align: right;"><?php print $element->getDisplayname()?>:</td><td><table><tr><td style="vertical-align: top;"><?php print $element->display($fieldAttributes);?></td><?php
	if(!$element->isValid()){
		?><td style="color: red;"><?php
		foreach($element->getErrors() as $error){
			print $error . "<br />";
		}
		?></td><?php
	}
?></td></tr></table></td></tr>			
			<?php
}
		?>
</table>
<?php
if(count($this->submits) > 0):
?>
<center>
<table>
<tr>
<?php
foreach($this->submits as $submit):
?>
<td><?php print $submit->display();?></td>
<?php
endforeach;
foreach($this->resets as $reset):
?>
<td><?php print $reset->display();?></td>
<?php
endforeach;
?>
</tr>
</table>
</center>
<?php
endif;
?>
</form>

